﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using CE.Security;
using CE.User;
using CE.Database;
using System.Data;
using System.Collections;

public partial class about_car_insurance_claim : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LiteralControl newln = new LiteralControl(Environment.NewLine);
        HtmlMeta language = new HtmlMeta();
        language.Name = "language";
        language.Content = "Thai";
        HtmlMeta contentlanguage = new HtmlMeta();
        contentlanguage.HttpEquiv = "content-language";
        contentlanguage.Content = "th";

        HtmlMeta keywords = new HtmlMeta();
        keywords.Name = "keywords";
        keywords.Content = "เคลมประกันภัยรถยนต์,ไม่มีคู่กรณี,เคลมแห้ง,เคลมสด,มีคู่กรณี,อุบัติเหตุ,รถชน,ประกันรถยนต์";
        HtmlMeta description = new HtmlMeta();
        description.Name = "description";
        description.Content = "วิธี เคลมประกันภัยรถยนต์ แบบไม่มีคู่กรณี (เคลมแห้ง) คือแจ้งหลังเกิดเหตุและ แบบมีคู่กรณี (เคลมสด) คือแจ้งเจ้าหน้าที่ประกันภัยมาที่เกิดเหตุเลย";

        Page.Header.Controls.AddAt(10, new LiteralControl(Environment.NewLine));
        Page.Header.Controls.AddAt(11, language);
        Page.Header.Controls.AddAt(12, new LiteralControl(Environment.NewLine));
        Page.Header.Controls.AddAt(13, contentlanguage);
        Page.Header.Controls.AddAt(14, new LiteralControl(Environment.NewLine));
        Page.Header.Controls.AddAt(15, keywords);
        Page.Header.Controls.AddAt(16, new LiteralControl(Environment.NewLine));
        Page.Header.Controls.AddAt(17, description);

        HtmlLink css = new HtmlLink();
        css.Href = Resources.Master.CssUrl;
        css.Attributes["rel"] = "stylesheet";
        css.Attributes["type"] = "text/css";
        css.Attributes["media"] = "screen";
        Page.Header.Controls.Add(css);

        if (!IsPostBack)
        {
            string _LogoutUrl = CE.Global.General.GetUrl("/user/log-out", Page);
            HttpCookie cookies = Request.Cookies["GGQuote"];
            if (cookies != null)
            {
                if (Session[CE.Global.General.UserId] == null)
                {
                    string Email = MySecurity.Decrypt(cookies.Values.Get("CustomerEmail"), true);
                    GetUserDetails(Email);
                }
                string _strRowguid = cookies.Value;
                string _strName = MySecurity.Decrypt(cookies.Values.Get("CustomerName"), true);
                if (_strName.Length > 15)
                {
                    _strName = _strName.Substring(0, 15).ToString().Trim() + "..";
                }
                string _Details = "<span class='tx-user left'>Hi, " + _strName + "</span> <span class='left'><a href='" + _LogoutUrl + "' class='nav' style='padding-left:5px;'> Not You?</a></span>";
                lblUserSlider.Text = _Details;
                lblUserHeader.Text = _Details;
                hplNavSignInSlider.Visible = false;
                hplNavSignInHeader.Visible = false;
            }
            else
            {
                lblUserSlider.Text = "";
                lblUserHeader.Text = "";
                //hplNavSignInSlider.Visible = true;
                //hplNavSignInHeader.Visible = true;
                hplNavSignInSlider.Visible = false;
                hplNavSignInHeader.Visible = false;
            }
            hplHomeSlider.NavigateUrl = CE.Global.General.GetUrl("/", Page);
            hplHomeHeader.NavigateUrl = CE.Global.General.GetUrl("/", Page);
            hplFooterHome.NavigateUrl = CE.Global.General.GetUrl("/", Page);

            hplNavCarInsuranceSlider.NavigateUrl = CE.Global.General.GetUrl("/car-insurance/car-details", Page);
            hplNavCarInsuranceHeader.NavigateUrl = CE.Global.General.GetUrl("/car-insurance/car-details", Page);

            //hplNavCarInsuranceSlider.NavigateUrl = CE.Global.General.GetUrl("/car-insurance/car-details", Page);
            hplNavFleetSlider.NavigateUrl = CE.Global.General.GetUrl("/car-fleet-insurance/", Page);
            hplNavSignInSlider.NavigateUrl = CE.Global.General.GetUrl("/car-insurance/sign-in", Page);
            //hplNavCarInsuranceHeader.NavigateUrl = CE.Global.General.GetUrl("/car-insurance/car-details", Page);
            hplNavFleetHeader.NavigateUrl = CE.Global.General.GetUrl("/car-fleet-insurance/", Page);
            hplNavSignInHeader.NavigateUrl = CE.Global.General.GetUrl("/car-insurance/sign-in", Page);
            hplNavPartnersSlider.NavigateUrl = CE.Global.General.GetUrl("/partners/", Page);
            hplNavPartnersHeader.NavigateUrl = CE.Global.General.GetUrl("/partners/", Page);

            hplFooterCI.NavigateUrl = CE.Global.General.GetUrl("/car-insurance/car-details", Page);
            hplFooterPromotion.NavigateUrl = CE.Global.General.GetUrl("/promotion/car-insurance-promotion", Page);
            hplAboutUs.NavigateUrl = CE.Global.General.GetUrl("/about-us/", Page);
            hplSavings.NavigateUrl = CE.Global.General.GetUrl("/savings/", Page);
            hplFAQ.NavigateUrl = CE.Global.General.GetUrl("/faq/", Page);
            hplPrivacy.NavigateUrl = CE.Global.General.GetUrl("/privacy/", Page);
            hplTerms.NavigateUrl = CE.Global.General.GetUrl("/terms/", Page);
            hplCarInsuranceBroker.NavigateUrl = CE.Global.General.GetUrl("/car-insurance-kb/car-insurance-broker.aspx", Page);
            hplSitemap.NavigateUrl = CE.Global.General.GetUrl("/sitemap/", Page);
            hplContactUs.NavigateUrl = CE.Global.General.GetUrl("/contact-us/", Page);
            hplNews.NavigateUrl = CE.Global.General.GetUrl("/news/", Page);
            hplMedia.NavigateUrl = CE.Global.General.GetUrl("/news/media", Page);
            hplCareers.NavigateUrl = CE.Global.General.GetUrl("/careers/", Page);
            hplTestimonials.NavigateUrl = CE.Global.General.GetUrl("/customer-testimonial/testimonial", Page);

            //aHome.HRef = CE.Global.General.GetUrl("~/home", Page);
            btnBuyNowTop.PostBackUrl = CE.Global.General.GetUrl("~/car-insurance/car-details", Page);
            aCallBack.HRef = CE.Global.General.GetUrl("~/car-insurance/call-me", Page);
            //aCallBack1.HRef = CE.Global.General.GetUrl("~/car-insurance/call-me", Page);
            alinkbroker.HRef = CE.Global.General.GetUrl("/car-insurance-kb/car-insurance-broker.aspx", Page);
            alinkhome.HRef = "www.gluaygluay.com";
            alinkaboutcarinsurance.HRef = CE.Global.General.GetUrl("/car-insurance-kb/", Page);
            aCallBack2.HRef = CE.Global.General.GetUrl("~/car-insurance/call-me", Page);
        }
    }

    private void GetUserDetails(string CustomerEmail)
    {
        try
        {
            AccountDB _accountdb = new AccountDB();
            Account _account = _accountdb.GetUserAccount(CustomerEmail.ToLower(), Convert.ToInt32(CE.Global.CEUserType.Customer));
            if (_account != null)
            {
                Session[CE.Global.General.UserId] = _account.CEID;
                Session[CE.Global.General.UserTypeId] = _account.UserTypeId;
                Session[CE.Global.General.UserEmail] = _account.Email;

                Profile _profile = new Profile();
                ProfileDB _profiledb = new ProfileDB();
                Contact _contact = new Contact();
                ContactDB _contactdb = new ContactDB();

                _contact = _contactdb.GetContact(_account.CEID);
                _profile = _profiledb.GetProfile(_account.CEID);

                if (_contact != null)
                {
                    Session[CE.Global.General.UserPhoneNo] = _contact.Mobile;
                }
                else
                {
                    Session[CE.Global.General.UserPhoneNo] = null;
                }
                if (_profile != null)
                {
                    if (_profile.FirstName != null && _profile.FirstName != string.Empty)
                    {
                        Session[CE.Global.General.UserName] = Server.HtmlDecode(_profile.FirstName) + " " + Server.HtmlDecode(_profile.SurName);
                    }
                    else
                    {
                        Session[CE.Global.General.UserName] = Server.HtmlDecode(_profile.SurName);
                    }
                    if (_profile.IsAcceptTC != null)
                    {
                        Session[CE.Global.General.IsAcceptTC] = "0";
                        if (_profile.IsAcceptTC == true)
                        {
                            Session[CE.Global.General.IsAcceptTC] = "1";
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
        }
    }

}
